﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Telerik.Web.UI;
//using _WebShared.Classes;

namespace KPIS.GERP.GAMS.APP.App_UI.UserControls
{
    public partial class DatePicker : System.Web.UI.UserControl
    {
        private void Page_Load(object sender, EventArgs e)
        {

        }

        public void SetValue(object date)
        {
            if (date == null)
            {
                txtDate.Value = "";
            }
            else
            {
                switch (date.GetType().ToString())
                {
                    case "System.DateTime":
                        txtDate.Value = ((DateTime)date).ToShortDateString();
                        break;
                    case "System.String":
                    default:
                        txtDate.Value = date.ToString();
                        break;
                }
            }
        }

        public string GetStringValue()
        {
            string strDate = txtDate.Value;

            return strDate;
        }

        public Nullable<DateTime> GetDateValue()
        {
            string strDate = txtDate.Value;
            Nullable<DateTime> date;

            if (strDate.Length > 0)
            {
                date = Convert.ToDateTime(strDate);
            }
            else
            {
                date = null;
            }

            return date;
        }
        public void Enable(Boolean pFlag)
        {
            //txtDate.Disabled = !pFlag;
            //PanelDatePicker.Enabled = pFlag;
        }
        public void Clear(string pValue)
        {
            txtDate.Value = pValue;
        }
    }
}